package com.financing.wap.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.wap.common.SqlName;
import com.financing.wap.dao.IUserInfoDao;
import com.financing.wap.dao.wherecondition.WhereCondition;
import com.financing.wap.dto.UserInfoDTO;


@Repository("userInfoDaoImpl")
public class UserInfoDaoImpl extends BaseDaoImpl<UserInfoDTO, java.lang.String>  implements IUserInfoDao{

	public UserInfoDTO queryUserInfo(UserInfoDTO userInfoDTO) {
			return (UserInfoDTO) this.sqlMapClientTemplate.queryForObject(SqlName.UserInfoSql.queryUserInfo,userInfoDTO);
	}

	@Override
	public Class<UserInfoDTO> getEntityClass() {
		// TODO Auto-generated method stub
		return UserInfoDTO.class;
	}

	@Override
	public UserInfoDTO queryUserInfoForLicaishi(String loginName) {
		return (UserInfoDTO) this.sqlMapClientTemplate.queryForObject(SqlName.UserInfoSql.queryUserInfoForLicaishi,loginName);
	}

	@SuppressWarnings("unchecked")
	public List<UserInfoDTO> queryAllUserInfo(UserInfoDTO userInfoDTO) {
		try {
			return (List<UserInfoDTO>)this.sqlMapClientTemplate.queryForList(SqlName.UserInfoSql.queryUserInfo,userInfoDTO);
		} catch (Exception e) {
			this.log.error("Query all userInfo error:",e);
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public List<UserInfoDTO> queryOrgTree(WhereCondition wc) {
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("wc", wc);
			return (List<UserInfoDTO>)this.sqlMapClientTemplate.queryForList(SqlName.UserInfoSql.queryOrgTree, map);
		} catch (Exception e) {
			this.log.error("Query all userInfo error:",e);
			return null;
		}
	}
	
	/**
	 * 根据登录人获取组织下所有内部理财师telphone
	 */
	@Override
	public String queryPhoneLayerPath(WhereCondition wc) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("wc", wc);
		return (String) this.sqlMapClientTemplate.queryForObject(SqlName.UserInfoSql.queryPhoneLayerPath, map);
	}
	
	/**
	 * 根据登录人获取组织下所有内部理财师userid
	 */
	@Override
	public List<String> queryUseridByLayerPath(WhereCondition wc) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("wc", wc);
		return this.sqlMapClientTemplate.queryForList(SqlName.UserInfoSql.queryUseridByLayerPath, map);
	}


}
